#include <iostream>
#include <iomanip>
#include <string>
#include <clocale>
#include "Bit.h"
#include "Bitstr.h"
#include "Digsim.h"
#include "Omvandla.h"

using namespace std;

int main()
{
	setlocale (LC_ALL, "swedish");
	char sum;
	char cu;

	/*Bit test;
	cout << "AND" << endl;
	
	cout << "1,1 = " << test.and('1','1') << endl;
	cout << "1,0 = " << test.and('1','0') << endl;
	cout << "0,1 = " << test.and('0','1') << endl;
	cout << "0,0 = " << test.and('0','0') << endl;

	cout << "OR" << endl;
	cout << "1,1 = " << test.or('1','1') << endl;
	cout << "1,0 = " << test.or('1','0') << endl;
	cout << "0,1 = " << test.or('0','1') << endl;
	cout << "0,0 = " << test.or('0','0') << endl;

	cout << "XOR" << endl;
	cout << "1,1 = " << test.xor('1','1') << endl;
	cout << "1,0 = " << test.xor('1','0') << endl;
	cout << "0,1 = " << test.xor('0','1') << endl;
	cout << "0,0 = " << test.xor('0','0') << endl;

	cout << "ADD" << endl;
	cout << "0:0 ";
	test.add('0','0','0', sum, cu);
	cout << sum << cu << endl;
	cout << "0:1 ";
	test.add('0','1','0', sum, cu);
	cout << sum << cu << endl;
	cout << "1:0 ";
	test.add('1','0','0', sum, cu);
	cout << sum << cu << endl;
	cout << "1:1 ";
	test.add('1','1','0', sum, cu);
	cout << sum << cu << endl;
	cout << "0:0 (carry)";
	test.add('0','0','1', sum, cu);
	cout << sum << cu << endl;
	cout << "0:1 (carry) ";
	test.add('0','1','1', sum, cu);
	cout << sum << cu << endl;
	cout << "1:0 (carry) ";
	test.add('1','0','1', sum, cu);
	cout << sum << cu << endl;
	cout << "1:1 (carry) ";
	test.add('1','1','1', sum, cu);
	cout << sum << cu << endl;

	Bitstr test1;
	string Astring = "1001";
	string Bstring = "0110";
	string Summa;

	test1.addstr(Astring, Bstring, Summa);
	cout << "ADDSTR test 1" << endl; 
	cout << Summa << endl;

	string Astring2 = "10011111";
	string Bstring2 = "01101111";
	test1.addstr(Astring2, Bstring2, Summa);
	cout << "ADDSTR test 2" << endl;
	cout << Summa << endl;

	Omvandla omv_test;
	cout << "Binary_to_Decimal" << endl;
	cout << omv_test.Binary_to_Decimal("11111111") << endl;

	string str_test;
	cout << "Decimal to Binary" << endl;
	omv_test.Decimal_to_Binary(255, str_test, 8);
	cout << str_test << endl;*/

	Omvandla Digsim_omvandla;
	Bitstr Digsim_bitstr;
	string strA, strB, Answer;
	int A, B, nrbits;

	cout << "Enter number: ";
	cin >> A;
	cout << "Enter number: ";
	cin >> B;
	cout << "Enter number of bits: ";
	cin >> nrbits;

	Digsim_omvandla.Decimal_to_Binary(A, strA, nrbits);
	Digsim_omvandla.Decimal_to_Binary(B, strB, nrbits);

	cout << A << "dec = " << strA << "bin, " << B << "dec = " << strB << "bin" << endl;

	Digsim_bitstr.addstr(strA, strB, Answer);

	cout << A << "dec + " << B << "dec = " << Answer << "bin" << endl;

	cout << Answer << "bin = " << Digsim_omvandla.Binary_to_Decimal(Answer) << "dec" << endl;

	cout << endl;
	system("PAUSE");
	return 0;
}